<extend name="./Public/Home/master.html" />
<block name="title">
    </div>
    <!--导航结束-->
    <div class="clear"></div>

    </div>
    <!--头部结束-->
    <!--中间开始-->
    <div id="content">
        <!--判断购物车中是否有数据-->
        <?php if($data) { ?>
        <form action="{:U('Home/Order/getCartData')}" method="post">
            <div class="car main">
                <div class="carshop">
                    <div class="cartitle">
                        <div class="carcheck">
                            <div class="checkbox">
                                <span class="check checkon" id="allcheck"></span>
                            </div>
                            全选</div>
                        <div class="carname">商品名称</div>
                        <div class="carmoney">单价</div>
                        <div class="carnum">数量</div>
                        <div class="carcount">小计</div>
                        <div class="carhandle">操作</div>
                    </div>
                    <!--将购物车的数据循环遍历开始-->
                    <!--判断是否未登录，分别去不同的数据,如果有就读取数据库的商品数据-->
                    <?php if(session('home.uid')){ ?>
                    <foreach name="data" item="vo" key="k">
                        <div class="shopcontent">
                        <div class="shopcheck"><div class="checkbox">
                            <span class="check checkon "></span>
                            <input type="checkbox" name='caid[]' value="{$vo['caid']}" checked="checked" class="checkhide"/>
                        </div></div>
                        <div class="shopname">
                            <div class="carimg">
                                <a href=""><img src="__ROOT__/{$vo['pic']}"/></a>
                            </div>
                            <p>
                                <a href="#">{$vo['name']}</a><br>
                                <foreach name="vo['options']" key="kk" item="vv" >
                                <span>{$kk}：{$vv}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
                                </foreach>
                            </p>
                        </div>
                        <div class="shopmoney">{$vo['price']}&nbsp;元</div>
                        <div class="shopnum">

                            <a href="javascript:;" class="num_l" sid="{$k}">-</a>
                            <input type="text" value="{$vo['num']}" />
                            <a href="javascript:;" class="num_r" sid="{$k}">+</a>
                        </div>
                        <div class="shopcount">{$vo['total']}&nbsp;元</div>
                        <div class="shophandle"><span sid="{$k}" caid="{$vo['caid']}">x</span></div>
                    </div>
                    </foreach>
                    <!--如果没有登录就就读session的数据-->
                    <?php }else{ ?>
                    <foreach name="data" item="vo" key="k">
                        <div class="shopcontent">
                            <div class="shopcheck"><div class="checkbox">
                                <span class="check checkon "></span>
                                <input type="checkbox" name='sid[]' value="{$k}" checked="checked" class="checkhide"/>
                            </div></div>
                            <div class="shopname">
                                <div class="carimg">
                                    <a href=""><img src="__ROOT__/{$vo['pic']}"/></a>
                                </div>
                                <p>
                                    <a href="#">{$vo['name']}</a><br>
                                    <foreach name="vo['options']" key="kk" item="vv" >
                                        <span>{$kk}：{$vv}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
                                    </foreach>
                                </p>
                            </div>
                            <div class="shopmoney">{$vo['price']}&nbsp;元</div>
                            <div class="shopnum">

                                <a href="javascript:;" class="num_l" sid="{$k}" caid="{$vo['caid']}">-</a>
                                <input type="text" value="{$vo['num']}" />
                                <a href="javascript:;" class="num_r" sid="{$k}" caid="{$vo['caid']}">+</a>
                            </div>
                            <div class="shopcount">{$vo['total']}&nbsp;元</div>
                            <div class="shophandle"><span sid="{$k}" caid="{$vo['caid']}"
                             >x</span></div>
                        </div>
                    </foreach>

                    <?php } ?>
                    <!--将购物车的数据循环遍历结束-->

                </div>
                <div class="jiesuan">
                    <div class="jixu"><a href="">继续购物</a></div>
                    <div class="gongji">共计<span id="total_num">{$total_rows}</span>件商品</div>
                    <div class="heji">合计<span id="total_price">{$total}元</span></div>
                    <div class="gou">
                        <?php if(isset($_SESSION['home']['uid'])) { ?>
                            <input type="submit" value="去结算"/>
                        <?php }else{ ?>
                        <a style="display: block;width: 200px;text-align: center;color: #fff;line-height: 60px;background: #36aa3f;border: none;" href="{:U('Home/Login/login')}">去结算</a>
                    <?php } ?>
                    </div>
                </div>
            </div>

        </form>
        <?php }else{ ?>
            <div style="padding: 120px;text-align: center;font-size:20px;">亲:购物车空空如野,<a href="__ROOT__" style="color:red">继续购物</a></div>
        <?php  } ?>
    </div>
    </div>
    <!--中间结束-->
</block>